package com.ruoyi.web.controller.control;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.control.domain.PumpOperationRecord;
import com.ruoyi.control.service.IPumpOperationRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水泵操作记录Controller
 * 
 * @author ruoyi
 * @date 2024-12-07
 */
@RestController
@RequestMapping("/control/record")
public class PumpOperationRecordController extends BaseController
{
    @Autowired
    private IPumpOperationRecordService pumpOperationRecordService;

    /**
     * 查询水泵操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('control:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(PumpOperationRecord pumpOperationRecord)
    {
        startPage();
        List<PumpOperationRecord> list = pumpOperationRecordService.selectPumpOperationRecordList(pumpOperationRecord);
        return getDataTable(list);
    }

    /**
     * 查询水泵操作记录列表DECS
     */
    @PreAuthorize("@ss.hasPermi('control:record:list')")
    @GetMapping("/listDesc")
    public TableDataInfo listDesc(PumpOperationRecord pumpOperationRecord)
    {
        startPage();
        List<PumpOperationRecord> list = pumpOperationRecordService.selectPumpOperationRecordlistDesc(pumpOperationRecord);
        return getDataTable(list);
    }

    /**
     * 导出水泵操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('control:record:export')")
    @Log(title = "水泵操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PumpOperationRecord pumpOperationRecord)
    {
        List<PumpOperationRecord> list = pumpOperationRecordService.selectPumpOperationRecordList(pumpOperationRecord);
        ExcelUtil<PumpOperationRecord> util = new ExcelUtil<PumpOperationRecord>(PumpOperationRecord.class);
        util.exportExcel(response, list, "水泵操作记录数据");
    }

    /**
     * 获取水泵操作记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:record:query')")
    @GetMapping(value = "/{pumpOperationRecordId}")
    public AjaxResult getInfo(@PathVariable("pumpOperationRecordId") Long pumpOperationRecordId)
    {
        return success(pumpOperationRecordService.selectPumpOperationRecordByPumpOperationRecordId(pumpOperationRecordId));
    }

    /**
     * 新增水泵操作记录
     */
    @PreAuthorize("@ss.hasPermi('control:record:add')")
    @Log(title = "水泵操作记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PumpOperationRecord pumpOperationRecord)
    {
        return toAjax(pumpOperationRecordService.insertPumpOperationRecord(pumpOperationRecord));
    }

    /**
     * 修改水泵操作记录
     */
    @PreAuthorize("@ss.hasPermi('control:record:edit')")
    @Log(title = "水泵操作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PumpOperationRecord pumpOperationRecord)
    {
        return toAjax(pumpOperationRecordService.updatePumpOperationRecord(pumpOperationRecord));
    }

    /**
     * 删除水泵操作记录
     */
    @PreAuthorize("@ss.hasPermi('control:record:remove')")
    @Log(title = "水泵操作记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pumpOperationRecordIds}")
    public AjaxResult remove(@PathVariable Long[] pumpOperationRecordIds)
    {
        return toAjax(pumpOperationRecordService.deletePumpOperationRecordByPumpOperationRecordIds(pumpOperationRecordIds));
    }
}
